package com.enjoy.mjbaseframe.util;

import java.util.regex.Pattern;

/**
 * 正则表达式工具类
 * Created by Administrator on 2018/3/15.
 * 正则表达式参考：http://blog.csdn.net/dgs960825/article/details/51105344
 */

public class PatternUtil {
    //手机好正则表达式
    private static final String PATTERN_MOBILE = "^((13[0-9])|(15[^4])|(166)|(17[0-8])|(18[0-9])|(19[8-9])|(147,145))\\d{8}$";
    //验证密码(不包含特殊字符)
    public static final String PATTERN_PASSWORD = "^[a-zA-Z0-9]{6,16}$";

    /**
     * 正则表达式执行代码
     * @param regExp
     * @param str
     * @return
     */
    public static boolean matchPattern(String regExp,String str){
        return Pattern.matches(regExp, str);
    }

    /**
     * 手机号正则表达式
     * @param mobile 手机号码
     * @return
     */
    public static boolean isMobile(String mobile){
        return matchPattern(PATTERN_MOBILE,mobile);
    }

    public static boolean isPWD(String pwd){
        return matchPattern(PATTERN_PASSWORD,pwd);
    }


}
